package cn.hhy.org.mapper;

import cn.hhy.org.domain.Employee;
import cn.hhy.org.domain.Employee;
import cn.hhy.org.domain.Employee;
import cn.hhy.org.query.EmployeeQuery;
import cn.hhy.org.query.EmployeeQuery;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface EmployeeMapper {


    List<Employee> employeeLoadAll(EmployeeQuery employeeQuery);

    Long findEmployeeCountByQuery(EmployeeQuery employeeQuery);
    /**
     * 查询全部
     * @return
     */

    @Select("select * from t_employee")
    List<Employee> loadAll();
    /**
     * 新增
     * @param employee
     */
    @Insert("insert into t_employee (username, email, phone, salt, password, age,state,department_id,loginInfo_id,shop_id)\n" +
            "    values (#{username}," +
            "            #{email}," +
            "            #{phone}," +
            "            #{salt}," +
            "            #{password}," +
            "            #{age},#{state},#{loginInfo_id},#{shop_id},#{department.id});")
    void save(Employee employee);

    /**
     * 修改
     * @param employee
     */
    @Update("update t_employee set username=#{username}, email=#{email} ," +
            "phone=#{phone},salt=#{salt},password=#{password}," +
            "age=#{age}, state=#{state},department_id=#{department.id}, loginInfo_id=#{loginInfo_id} ,shop_id=#{shop_id} " +
            " where id=#{id};")
    void update(Employee employee);

    /**
     * 删除
     * @param id
     */
    @Delete( "delete from t_employee where id=#{id}")
    void delete(Long id);

    /**
     * 根据ID查询
     * @param id
     * @return
     */
    @Select("select * from t_employee where id=#{id}")
    Employee loadById(Long id);

    void PatchDelete(Long[] ids);


}
